export const state = () => ({
    user: {
        identity_card_id: "",
        user_type: "",
        identity_card_type: "",
        name: "",
        preference: ""
    },
    bankCards: []
});

export const getters = {
    isEmpty: state => {
        return state.user.name === "";
    },
    userInfo: state => {
        return state.user;
    },
    bankCards: state => {
        return state.bankCards;
    }
};

export const mutations = {
    setUserInfo(state, user) {
        state.user = user;
    },
    setPreference(state, preference) {
        state.user.preference = preference;
    },
    addBankCard(state, {type: type, card: card}) {
        state.bankCards.push({type: type, card: card});
    },
    setBankCards(state, bankCards) {
        state.bankCards = bankCards;
    },
    clear(state) {
        state.user = {
            identity_card_id: "",
            user_type: "",
            identity_card_type: "",
            name: "",
            preference: ""
        };
        state.bankCards = [];
    },
};
